package com.otp.Activity;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.MediaController;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.VideoView;

import com.otp.customUI.NavigationView;
import com.otp.util.Constants;

import java.net.URI;
import java.net.URL;

public class CourseDetail extends BaseActivity implements View.OnClickListener{
    private TextView back = null;
    private NavigationView titleBar = null;
    private VideoView videoView = null;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_course_detail);
        Intent intent = this.getIntent();
        titleBar = (NavigationView) findViewById(R.id.courseNameTitle);
        int courseId = intent.getIntExtra(Constants.COURSE_ID, 0);
        String courseName = intent.getStringExtra(Constants.COURSE_NAME);
        String coursePath = intent.getStringExtra(Constants.COURSE_VIDEO_PATH);
        titleBar.setTitle(courseName);
        back = (TextView) findViewById(R.id.iv_nav_back);
        back.setOnClickListener(this);
        videoView = (VideoView) findViewById(R.id.courseVideo);
        Uri uri = Uri.parse(coursePath);
        videoView.setVideoURI(uri);
        videoView.requestFocus();
        videoView.start();
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.iv_nav_back:
                this.finish();
                break;
            default:
                ;
                break;
        }
    }
}
